print('1.继承')
print('方法重写:如何子类对继承自父类的某个属性和方法不忙以，可以在子类中对其(方法体)进行重新编写\n'
      '子类重写的方法可以通过super.xxx()调用父类中被重写过的方法')
#父类
class Person(object):
    def __init__(self, name, age):
        self.name = name
        self.age = age
    def info(self):
        print("姓名:", self.name, "年龄:", self.age)
#子类
#学生类
class Student(Person):
    def __init__(self, name, age, score):
        super().__init__(name,age)
        self.score = score
    #重写父类Person中的info方法
    def info(self):
        super().info()
        print("成绩:", self.score)
#教师类
class Teacher(Person):
    def __init__(self, name, age, teacherage):
        super().__init__(name,age)
        self.teacherage = teacherage
    # 重写父类Person中的info方法
    def info(self):
        super().info()
        print("教龄:", self.teacherage)
stu = Student("张三",23,90)
tea = Teacher('张老师', 45, 10)
stu.info()
print("----------")
tea.info()
